/**
 * 浙江齐聚科技有限公司版权所有
 * Copyright (C) qiju Corporation. All Rights Reserved
 */
package com.sunkai.math;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class TestFileRead {
	public static void main(String[] args) throws IOException {
		File file = new File("E:\\tttt2.txt");
		InputStreamReader isr = new InputStreamReader(new FileInputStream(file));
		BufferedReader bf = new BufferedReader(isr);
		StringBuilder bfer = new StringBuilder();
		
		String line = null;
		while ((line = bf.readLine())!=null){
			bfer.append(line);
		}
		System.out.println("----");
		long startTime = System.currentTimeMillis();
		char[] a = bfer.toString().toCharArray();
		StringBuilder  buf= new StringBuilder();
		//z1234576783合适的刚\r\n2342fd\t435345345kkk
		int begin = 0;
		int end = 0;
		for(int i = 0;i<a.length ;i++){
			if(check(a[i])==true && check(a[i-1])==false && check(a[i+1]) == false){
				buf.append(bfer.toString().substring(i, i+1)+",");
				continue;
			}
			
			if(i!=0){//开始
				if(check(a[i])==true && check(a[i-1])==false && check(a[i+1]) == true){
					begin = i;
				}
			}

			if(i!=a.length-1){//结束
				if(check(a[i])==true && check(a[i-1])==true &&check(a[i+1]) == false){
					end = i;
					buf.append(bfer.toString().substring(begin, end+1)+",");
				}
			}
		}
		
		System.out.println(System.currentTimeMillis()-startTime);
	}
	
	public static boolean check(char c){
		/*if (c>='0' && c<='9') {
			return true;
		}
		return false;*/
		try {
			Integer.parseInt(String.valueOf(c));
			return true;
		} catch (Exception e) {
			return false;
		}
	}
}
